<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .outer {
            width:300px;
            height: 200px;
            overflow: hidden;
            margin: 0 auto;
        }
        .inner {
            background: black;
            width: 1500px;
            height: 200px;
            float: left;
        }
        img {
            width: 300px;
            height: 200px;
            float: left;
        }
        button {
            border: none;
            outline: none;
            width: 50px;
            height: 200px;
            font-size: 40px;
            font-weight: 100;
            background: none;
            color: white;
        }

        #right_btn {
            position: absolute;
            top: 100px;
            left: 790px;
        }
        #left_btn {
            position: absolute;
            top: 100px;
            left: 527px;
        }
    </style>
    <script src="jquery.min.js"></script>
</head>
<body>
<div class="outer" id="outer">
    <div class="inner" id="inner">
        <img src="1.jpg">
        <img src="2.jpg">
        <img src="3.jpg">
        <img src="4.jpg">
    </div>
</div>
    <button id="left_btn"><</button>
    <button id="right_btn">></button>
<script>
    var left_btn = document.getElementById('left_btn');
    var right_btn = document.getElementById('right_btn');
    var inner = document.getElementById('inner');
    var number=0;
    var number1 = -1200;
    var first_img = inner.children[0];
    inner.appendChild(first_img.cloneNode());
    left_btn.onclick = function () {
        var interval = setInterval(
            function () {
                if(number===-1200){
                    number=0
                }else{
                        number -= 10;
                        if(number%300===0){
                            clearInterval(interval)
                        }
                }
                num = number+'px';
                inner.style.marginLeft = num
            },50
        );
    };
    right_btn.onclick = function () {
        var interval = setInterval(
            function () {
                if(number1===0){
                    // number1 += 10;
                    number1=-1200
                }else{
                        number1 += 10;
                        if(number1%300===0){
                            clearInterval(interval)
                        }
                }
                console.log(number1);
                num = number1+'px';
                inner.style.marginLeft = num
            },50
        );
    };

</script>
</body>
</html>